package org.yanfengying;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.yanfengying.user.interceptor.LoginInterceptor;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 启动类
 * 测试
 */
@SpringBootApplication
//配置mapper扫描
@MapperScan("org.yanfengying.*.mapper")
@EnableSwagger2
public class AppStart implements WebMvcConfigurer {
    public static void main(String[] args) {
        SpringApplication.run(AppStart.class, args);
    }

    @Autowired
    private LoginInterceptor loginInterceptor;
    //配置拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//拦截
                //放行地址
                .excludePathPatterns("/logininfo/**")
                .excludePathPatterns("/user/register/**")
                .excludePathPatterns("/user/bind/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/fastdfs");

    }
}
